import React, { Component } from 'react';
import {
  KeyboardAvoidingView, Platform,
  StyleSheet, Text, Modal, Alert, TextInput,
  PixelRatio, View, Image, ScrollView,
  TouchableOpacity
} from "react-native";
import { GLOBAL } from '../../../config/global';
import { style } from '../../../theme/style';
import { Common } from '../../../component/common/Common.js';
import { API, API_GENERATE } from '../../../config/api';
import HTTP from '../../../utils/http';
import ToastUtil from '../../../utils/toast';
import { Loading } from '../../../component/page-status/Pageloading';
import MethodUtil from '../../../utils/MethodUtil';
import { orderBaseStyle } from '../../order-new/create/_common/style.js';
import navigationSeevice from '../../../components/navigation/navigationSeevice';
import OrderNewOilCreactService from '../_common/service';
import { NavigationEvents } from 'react-navigation';

const scale = GLOBAL.SCALE;
const selectIcon = require('../../../imgs/global/down.png');
export class SinoNewRelevanceOrderList extends Component {
  static navigationOptions = ({ navigation }) => {
    return {
      headerTitle: '采购批次关联',
      headerLeft: <Common type="headLeft" onPress={() => { navigation.goBack() }} />,
      headerRight: (<Image style={style.head.headRightEmpty} source={require('../../../imgs/goBackEmpty.png')} />),
      headerStyle: {  // 头部整体样式 
        elevation: 0,
        backgroundColor: '#fff',
        borderBottomWidth: 0
      },
      headerTitleStyle: {
        flex: 1,
        textAlign: 'center'
      }
    }
  };

  requesting
  constructor(props) {
    super(props);
    console.log('params', props.navigation.state.params)
    let { sendData } = props.navigation.state.params || {};
    let { zxyOrderItemTOs, zxyOrderInfoTO } = sendData || {};
    this.state = {
      totalPlanGrossProfit: 0,
      totalMappingProfit: 0,
      orderTotalQuantity: 0, //毛利计算规则展示的订单总量
      orderTotalMapping: 0, //毛利计算规则展示的总关联量
      pbocPrice: 0
    }

    this.sendData = sendData;
    this.productsList = zxyOrderItemTOs || [];
    this.orderInfo = zxyOrderInfoTO || {};
  }

  componentWillMount() {
    this.init();
    this.getOrderMapping();
  }

  init() {
    let orderTotalQuantity = 0; //订单总量
    let totalPlanGrossProfit = 0; //订单总额
    this.productsList.map((item, index) => {
      orderTotalQuantity = orderTotalQuantity + parseFloat(item.quantity);
      totalPlanGrossProfit = totalPlanGrossProfit + MethodUtil.countObj.multiply(item.nakedPrice, item.quantity, 2);
    })
    this.setState({
      orderTotalQuantity,
      totalPlanGrossProfit
    })
  }

  //草稿（新增）查询本地已关联列表-new  
  async getOrderMapping() {
    let totalMappingProfit = 0; //总关联毛利
    let orderTotalMapping = 0; //总关联量
    let pbocPrice = 0; //汇率
    let response = await HTTP.POST(API_GENERATE(API.ZXY_LOCAL_USED_MAPPING_LIST), { orderId: this.orderInfo.orderId });
    if (!response || !response.length) {
      response = [];
      this.productsList.map((item, index) => {
        response[index] = {};
        response[index]['groupName'] = item.goodsName;
        response[index]['availableQuantity'] = item.quantity;
        response[index]['totalQuantity'] = item.quantity;
        response[index]['orderInfo'] = {};
        response[index]['orderInfo']['goodsId'] = item.goodsId;
        response[index]['orderInfo']['batchNo'] = item.batchNo;
        response[index]['orderInfo']['orderId'] = this.orderInfo.orderId;
        response[index]['orderInfo']['companyName'] = this.orderInfo.companyName;
      })
    } else {
      /* 
        average : 均价  均价 = (关联总价格 / 关联总数量 )   关联总价格 = 多个关联累加(关联价格*关联数量)
        expectALl : 总毛利  关联3个订单 3个毛利累加 就是 总毛利
        expectSingle : 预计毛利   预计毛利 =(XX销售单价 - 关联采购均价)*关联量
      */
      response.map((item, index) => {
        let quantity = 0;
        let expectALl = 0; //总毛利
        let average = this._average(item.stockMappingList) || 0; // 均价 
        item.expect = parseFloat(item.orderInfo.originPrice || 0) - average;//差价
        pbocPrice = item.orderInfo.pbocPrice; //汇率
        item.stockMappingList && item.stockMappingList.map(async (mapping, i) => {
          const { lockedTO } = mapping;
          // 单商品总关联数量
          quantity = MethodUtil.countObj.add((quantity || 0), (lockedTO.lockedQuantity || 0), 2);
          item.lockedQuantity = quantity;
          // 单关联毛利
          mapping.expectSingle = MethodUtil.countObj.multiply((item.expect || 0), (lockedTO.lockedQuantity || 0), 2);
          // 单商品总毛利
          expectALl = MethodUtil.countObj.add((expectALl || 0), (mapping.expectSingle || 0), 2);

        })

        this.productsList && this.productsList.length && this.productsList.map((proItem, index) => {
          if (proItem.goodsId === item.orderInfo.goodsId) {
            //单商品总（待关）量
            item.totalQuantity = proItem.quantity || 0;
            // 单商品总待关联量=单商品总量-单商品已关联量
            item.availableQuantity = MethodUtil.countObj.subtract((proItem.quantity || 0), (item.lockedQuantity || 0), 2);
          }
        })
        // 订单总毛利
        totalMappingProfit = MethodUtil.countObj.add((totalMappingProfit || 0), (expectALl || 0), 2);
        // 毛利计算规则展示该订单总关联量
        orderTotalMapping = MethodUtil.countObj.add((orderTotalMapping || 0), (item.lockedQuantity || 0), 2);
        // 均价
        item.average = average;
        // 总毛利
        item.expectALl = expectALl;
      })
    }
    this.setState({
      orderMappingInfo: response,
      totalMappingProfit,
      orderTotalMapping,
      pbocPrice
    })
  }

  //输入关联数量
  changeMapping(txt, productIndex, mappingIndex) {
    let { orderMappingInfo } = this.state;
    let totalMappingProfit = 0;
    let orderTotalMapping = 0;

    orderMappingInfo && orderMappingInfo.length && orderMappingInfo.map((item, index) => {
      let expectALl = 0;//单商品总毛利
      let totalQuan = 0;// 单商品总关联量
      let average = 0;
      item.stockMappingList && item.stockMappingList.length && item.stockMappingList.map((mapping, indexM) => {
        const { lockedTO } = mapping;
        if (productIndex === index && mappingIndex === indexM) {
          lockedTO.lockedQuantity = parseFloat(txt || 0);
        }
      })
      average = this._average(item.stockMappingList) || 0; // 均价 
      item.expect = parseFloat(item.orderInfo.originPrice || 0) - average;//差价
      item.stockMappingList && item.stockMappingList.length && item.stockMappingList.map((mapping, indexM) => {
        const { lockedTO } = mapping;
        totalQuan = totalQuan + (lockedTO.lockedQuantity || 0);
        // 单关联毛利
        mapping.expectSingle = MethodUtil.countObj.multiply(item.expect, lockedTO.lockedQuantity, 2);
        // 单商品总毛利
        expectALl = MethodUtil.countObj.add(expectALl, mapping.expectSingle, 2);
      })
      if (productIndex === index) {
        // 单商品总关联量
        item.lockedQuantity = totalQuan;
        // 单商品总毛利
        item.expectALl = expectALl;
      }
      // 均价
      item.average = average;
      // 计算合计利润
      totalMappingProfit = totalMappingProfit + (item.expectALl || 0);
      //毛利计算规则展示该订单总关联量
      orderTotalMapping = orderTotalMapping + (item.lockedQuantity || 0);
    })

    this.setState({
      orderMappingInfo,
      totalMappingProfit,
      orderTotalMapping
    })
  }

  //光标移出校验
  checkQuantity(groupName, lockedQuantity, availableQuantity, expectSingleLockedQuantity, expectSingleAvailableQuantity) {
    const { orderTotalMapping, orderTotalQuantity } = this.state;

    let inputMapping = parseFloat(this.curItemInputText || lockedQuantity || 0);
    let onMapping = parseFloat(availableQuantity)
    if (inputMapping <= 0) {
      ToastUtil.showWarning('关联量必须大于0');
      return false;
    }
    if (inputMapping > onMapping) {
      ToastUtil.showWarning(`关联量不能大于可关联量`);
      return false;
    }
    if (expectSingleLockedQuantity > expectSingleAvailableQuantity) {
      ToastUtil.showWarning(`${groupName}关联总量不能大于待关联量`);
      return false;
    }
    if (orderTotalMapping > orderTotalQuantity) {
      ToastUtil.showWarning(`已关联量不能大于订单总量`);
      return false;
    }
  }

  addMapping(index, orderInfo) {
    const { orderMappingInfo } = this.state;
    this.props.navigation.navigate('SinoNewProjectListPage', {
      orderMappingInfo: orderMappingInfo[index],
      orderInfo,
      callBack: (data) => {
        this.getOrderMapping();
      }
    })
  }

  //删除关联计划
  async _removeMappingItemFn(productIndex, mappingIndex) {
    let { orderMappingInfo } = this.state;
    if (orderMappingInfo && orderMappingInfo.length) {
      this.delMapping(orderMappingInfo[productIndex].orderInfo, orderMappingInfo[productIndex].stockMappingList[mappingIndex]);
      orderMappingInfo[productIndex].stockMappingList.splice(mappingIndex, 1);
    }
  }
  //删除关联计划
  async delMapping(productInfo, mappingItem) {
    const { orderId, batchNo } = productInfo || {};
    const { orderInfo } = mappingItem || {};
    let params = {
      orderId,
      batchNo,
      mappingOrderId: orderInfo.orderId,
      mappingBatchNo: orderInfo.batchNo
    }
    const response = await HTTP.POST(API_GENERATE(API.ZXY_DEL_MAPPING_LIST), params);
    if (response) {
      await this.getOrderMapping();
    }
  }

  //提交(下一步) submitType==0 保存 ，submitType==1 提交
  _submitFn = async (submitType) => {
    if (this.requesting) return;
    this.requesting = true;
    if (this.filter()) {
      this.setState({ status: 'loading' });
      this.sendData.operateType = submitType;
      let response = await HTTP.POST(API_GENERATE(API.ZXY_ORDER_ADD), this.sendData);
      this.setState({ status: 'data' });
      if (response) {
        await this.saveMapping(0, submitType);
      }
    } else {
      this.requesting = false;
    }
  }

  //保存-提交关联列表
  async saveMapping(type, submitType) {
    let { orderMappingInfo } = this.state;
    let orderMappingList = [];
    orderMappingInfo && orderMappingInfo.length && orderMappingInfo.map((item, index) => {
      const { stockMappingList, orderInfo } = item || {};
      const { orderId, batchNo, goodsId } = orderInfo || {};
      stockMappingList && stockMappingList.length && stockMappingList.map((stockMappingItem, i) => {
        const { lockedTO } = stockMappingItem;
        let checkItem = {
          orderId,
          batchNo,
          goodsId,
          mappingOrderId: stockMappingItem.orderInfo.orderId,
          mappingBatchNo: stockMappingItem.orderInfo.batchNo,
          mappingQuantity: lockedTO.lockedQuantity
        }
        orderMappingList.push(checkItem);
      })
    })
    const addApi = submitType == 'SUBMIT' ? API.ZXY_ADD_MAPPING_LIST : API.ZXY_LOCAL_SAVE_MAPPING_LIST
    const response = await HTTP.POST(API_GENERATE(addApi), orderMappingList);
    if (response && type !== 'delete') {
      ToastUtil.showSuccess(submitType == 'SUBMIT' ? '提交成功' : '保存成功').then(() => {
        OrderNewOilCreactService.reset();
      }).catch(err => {
        this.requesting = false;
      })
    } else {
      this.requesting = false;
    }
  }

  /*
    * 校验
    * type==1 销售成交
  */
  filter() {
    let { orderMappingInfo, orderTotalMapping, orderTotalQuantity, totalMappingProfit } = this.state;
    if (!orderMappingInfo || !orderMappingInfo.length) return true;
    //校验关联总和
    for (let i = 0; i < orderMappingInfo.length; i++) {
      const { stockMappingList, groupName, totalQuantity, expectALl } = orderMappingInfo[i] || {};
      if (!stockMappingList || !stockMappingList.length) return true;
      for (let j = 0; j < stockMappingList.length; j++) {
        const { lockedTO, orderInfo, expectSingle } = stockMappingList[j] || {};
        if (lockedTO.lockedQuantity <= 0) {
          ToastUtil.showWarning(`${groupName}关联${orderInfo.orderId}量必须大于0！`);
          return false;
        } else if (lockedTO.lockedQuantity > lockedTO.availableQuantity) {
          ToastUtil.showWarning(`${orderInfo.orderId}关联量不能大于可关量`);
          return false;
        } else if (lockedTO.lockedQuantity > totalQuantity) {
          ToastUtil.showWarning(`${groupName}关联总量不能大于待关联量`);
          return false;
        }
        // if (expectSingle <= 0) {
        //   ToastUtil.showWarning(`${groupName}关联${orderInfo.orderId}毛利必须大于零！`);
        //   return false;
        // } else if (expectALl <= 0) {
        //   ToastUtil.showWarning(`${groupName}预计毛利必须大于零！`);
        //   return false;
        // }
      }
    }

    if (orderTotalMapping > orderTotalQuantity) {
      ToastUtil.showWarning(`已关联量不能大于订单总量`);
      return false;
    }

    // if (totalMappingProfit <= 0) {
    //   ToastUtil.showWarning(`订单总毛利必须大于零！`);
    //   return false;
    // }

    return true;
  }

  //均价
  _average = (stockMappingList) => {  // 均价 = (关联总价格 / 关联总数量 )   关联总价格 = 多个关联累加(关联价格*关联数量)
    let tolPrice = 0;
    let tolQuantity = 0;
    stockMappingList && stockMappingList.forEach(item => {
      const { lockedTO, orderInfo } = item;
      tolQuantity = tolQuantity + (lockedTO.lockedQuantity || 0); //多个已关联总量
      tolPrice = tolPrice + (orderInfo.originPrice || 0) * (lockedTO.lockedQuantity || 0);  //多个已关联总价
    })
    if (tolQuantity) {
      return MethodUtil.countObj.divide(tolPrice, tolQuantity, 2) || 0;
    } else {
      return 0
    }
  }

  //采购成交
  _sellView = () => {
    const { orderMappingInfo } = this.state;
    return (
      <View>
        {
          orderMappingInfo && orderMappingInfo.length ?
            orderMappingInfo.map((orderMapping, index) => {
              let { groupName, orderInfo, lockedQuantity, stockMappingList, totalQuantity, average, expectALl } = orderMapping;
              return (
                <View key={index} style={styles.itemBox}>
                  <Text style={[styles.headBtn, styles.headBtnActive]} onPress={() => { this.addMapping(index, orderInfo) }}>关联采购</Text>
                  <View style={[styles.head, styles.xian]}>
                    <View style={[styles.rowbt, styles.ptop]}>
                      <Text style={[styles.bold, { fontSize: 14 * scale }]}>{groupName ? (groupName.length > 20 ? groupName.substr(0, 20) + "..." : groupName) : ""}</Text>
                      <Text style={styles.bold}>采购均价 <Text style={styles.fontSize16}>$ {MethodUtil.toThousands(average || 0, 2) || '-'}/吨</Text></Text>
                    </View>
                    <View style={styles.rowbt}>
                      <View style={styles.rowItem}>
                        <Text style={styles.norl}>已关联</Text>
                        <Text style={styles.bold}><Text style={styles.fontSize16}>{parseFloat(lockedQuantity || 0).toFixed(3) || 0}</Text> 吨</Text>
                      </View>
                      <View style={styles.rowItem}>
                        <Text style={styles.norl}>待关联</Text>
                        <Text style={styles.bold}><Text style={styles.fontSize16}>{parseFloat(totalQuantity - (lockedQuantity || 0)).toFixed(3) || 0}</Text> 吨</Text>
                      </View>
                      <View style={styles.rowItem}>
                        <Text style={styles.norl}>预计毛利</Text>
                        <Text style={[styles.bold, styles.ctInputTextRed]}><Text style={styles.fontSize16}>{MethodUtil.toThousands(expectALl || 0, 2) || 0}</Text> 美元</Text>
                      </View>
                    </View>
                  </View>
                  {
                    stockMappingList && stockMappingList.length ?
                      stockMappingList.map((item, i) => {
                        const { lockedTO, orderInfo } = item || {};
                        const { lockedQuantity, availableQuantity } = lockedTO || {};
                        const { companyName, orderId, originPrice } = orderInfo || {};
                        return (
                          <View key={i} style={styles.contian}>
                            <Text style={styles.removeText} onPress={() => { this._removeMappingItemFn(index, i) }}>删</Text>
                            <Text style={styles.ctTitle}>{companyName && companyName.length > 20 ? companyName.substr(0, 20) + "..." : (companyName || '-')} | {orderId || '-'}</Text>
                            <View style={[styles.ctInputBox, { flexWrap: 'wrap' }]}>
                              <View style={styles.ctInputBox}>
                                <TextInput
                                  style={styles.ctInput}
                                  keyboardType='numeric'
                                  defaultValue={(lockedQuantity || 0) + ''}
                                  onBlur={() => this.checkQuantity(groupName, lockedQuantity, availableQuantity, orderMapping.lockedQuantity, totalQuantity)}
                                  onChangeText={(txt) => { this.changeMapping(txt, index, i); this.curItemInputText = txt; }}
                                />
                                <Text style={styles.money}>吨 | </Text>
                              </View>
                              <Text style={styles.money}>$ {(originPrice || 0).toFixed(2)}/吨 | </Text>
                              <Text style={styles.money}>可关{availableQuantity || '-'}吨 | </Text>
                              <Text style={styles.money}>毛利：<Text style={styles.ctInputTextRed}> {MethodUtil.toThousands(item.expectSingle || 0, 2) || '-'} 美元</Text></Text>
                            </View>
                          </View>
                        )
                      }) : <View style={styles.emptyView}>
                        <Text style={styles.emptyText}>暂无关联任何采购计划 </Text>
                      </View>
                  }
                </View>
              )
            }) : null
        }
      </View>
    )
  }

  render() {
    let { totalMappingProfit, orderTotalMapping, orderTotalQuantity, totalPlanGrossProfit, pbocPrice } = this.state;
    let rnbProfit = MethodUtil.countObj.multiply(totalMappingProfit, pbocPrice, 2);
    let rnbAmt = MethodUtil.countObj.multiply(totalPlanGrossProfit, pbocPrice, 2);
    return (
      <View style={styles.container}>
        <NavigationEvents
          onDidBlur={async ({ action }) => {
            this.requesting = false;
          }}
        />
        <KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : null} keyboardVerticalOffset={20} >
          <ScrollView style={{ marginBottom: 132 * scale }}>
            {this._sellView()}
          </ScrollView>
        </KeyboardAvoidingView>
        <View style={styles.bottom}>
          <View style={styles.btnBox}>
            <TouchableOpacity style={[styles.btnPre, styles.btnPreActive]} onPress={() => this._submitFn('SUBMIT')}>
              <Text style={[styles.btnText, { color: '#fff' }]}>提交</Text>
            </TouchableOpacity>
            <TouchableOpacity style={[styles.btnPre, { marginRight: 0 * scale, marginLeft: 11 * scale }]} onPress={() => this._submitFn('SAVE')}>
              <Text style={styles.btnText}>保存</Text>
            </TouchableOpacity>
          </View>
          <Text style={styles.bottomText}>合计：总量 {orderTotalQuantity || '-'} 吨，总额：$ {MethodUtil.toThousands(totalPlanGrossProfit || 0, 2) || '-'}美元（折合人民币：¥{MethodUtil.toThousands(rnbAmt || 0, 2)}元）</Text>
          <Text style={styles.bottomText}>关联{orderTotalMapping || '-'}吨，毛利{MethodUtil.toThousands(totalMappingProfit || 0, 2) || '-'}美元（折合人民币：¥{MethodUtil.toThousands(rnbProfit || 0, 2)}元）</Text>
        </View>
        {
          this.requesting ? (<View style={orderBaseStyle.statusStyle}><Loading /></View>) : null
        }
      </View>
    )
  }
}
const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#F4F7FE'
  },
  tabBox: {
    width: '100%',
    height: 34 * scale,
    borderWidth: 1 / PixelRatio.get(),
    borderColor: style.color.themeColor,
    flexDirection: 'row',
    alignItems: 'center',
  },
  xian: {
    borderBottomWidth: 1 / PixelRatio.get(),
    borderStyle: 'solid',
    borderBottomColor: '#E3E7F0',
  },
  itemTab: {
    width: '50%',
    height: 33 * scale,
    lineHeight: 33 * scale,
    textAlign: 'center',
    color: style.color.themeColor,
    backgroundColor: style.color.white,
  },
  itemTabActive: {
    backgroundColor: style.color.themeColor,
    color: style.color.white
  },
  subtitle: {
    display: 'flex',
    flexDirection: 'row',
    alignItems: 'center'
  },
  rules: {
    textAlign: 'left',
    fontSize: 13 * scale,
    color: style.color.themeColor,
    paddingTop: 15 * scale,
    marginBottom: 5 * scale
  },
  total: {
    flex: 1,
    textAlign: 'right',
    fontSize: 13 * scale,
    paddingTop: 15 * scale,
    marginBottom: 5 * scale
  },
  colorActive: {
    color: style.color.lightRed
  },
  itemBox: {
    backgroundColor: style.color.white,
    width: '100%',
    borderRadius: 4 * scale,
    paddingTop: 10 * scale,
    paddingBottom: 10 * scale,
    paddingLeft: 12 * scale,
    paddingRight: 12 * scale,
    marginBottom: 20 * scale
  },
  head: {
    borderBottomWidth: 1 / PixelRatio.get(),
    borderStyle: 'solid',
    borderBottomColor: style.color.gray,
    position: 'relative',
    paddingBottom: 10 * scale
  },
  headBtn: {
    fontSize: 13 * scale,
    color: style.color.themeColor,
    //position: 'absolute',
    right: 0,
    top: 0,
    //marginBottom: 10 * scale
  },
  headBtnActive: {
    textAlign: 'right'
  },
  headTitle: {
    fontWeight: 'bold',
    color: style.color.black,
    marginBottom: 10 * scale
  },
  headInfo: {
    fontSize: 13 * scale,
  },
  contian: {
    paddingTop: 10 * scale,
    paddingBottom: 10 * scale,
    position: 'relative'
  },
  ctTitle: {
    fontSize: 12 * scale,
    width: 290 * scale
  },
  ctItem: {
    flexDirection: 'row',
    alignItems: 'center',
  },
  ctItemLable: {
    color: '#999',
    width: 65 * scale,
    fontSize: 13 * scale,
  },
  ctItemText: {
    fontSize: 13 * scale,
    lineHeight: 26 * scale,
  },
  noData: {
    textAlign: 'center',
    paddingTop: 25 * scale,
    paddingBottom: 25 * scale
  },
  removeText: {
    fontSize: 12 * scale,
    lineHeight: 26 * scale,
    position: 'absolute',
    right: -10 * scale,
    top: 8 * scale,
    zIndex: 9,
    color: style.color.themeColor,
    paddingLeft: 10 * scale,
    paddingRight: 10 * scale,
  },
  btnBox: {
    flexDirection: 'row',
    alignItems: 'center',
    justifyContent: 'center',
    height: 50 * scale,
    backgroundColor: 'rgba(0,0,0,0)',
    position: 'absolute',
    bottom: 10 * scale,
    left: 0,
    width: '100%',
  },
  emptyView: {
    width: '100%',
    borderTopWidth: 1 / PixelRatio.get(),
    borderStyle: 'solid',
    borderTopColor: style.color.gray,
    paddingTop: 25 * scale,
    paddingBottom: 20 * scale,
    alignItems: 'center'
  },
  modalBox: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: 'rgba(0,0,0,0.5)',
  },
  rulesCont: {
    height: '80%',
    width: '90%',
    backgroundColor: '#fff',
    shadowColor: '#D2D2D2',
    // shadowOffset: { width: 6 * scale, height: 6 * scale },
    shadowRadius: 2,
    shadowOpacity: 0.5,
    borderRadius: 8 * scale
  },
  rulesTitle: {
    flexDirection: 'row',
    alignItems: 'center',
    justifyContent: 'space-between',
  },
  rulesClose: {
    fontSize: 26 * scale,
    color: '#000',
    textAlign: 'right',
    marginRight: 12 * scale,
  },
  rulesTitleText: {
    fontSize: 16 * scale,
    color: '#000',
    textAlign: 'left',
    marginLeft: 12 * scale,
  },
  rulesTotalCard: {
    flexDirection: 'row',
    alignItems: 'center',
    justifyContent: 'center',
    backgroundColor: '#f4f7fe',
    borderRadius: 8 * scale,
    margin: 12 * scale,
    padding: 12 * scale,
    marginBottom: 0
  },
  rulesTotalCardItem: {
    flex: 1,
  },
  rulesTotalCardLabel: {
    marginBottom: 10 * scale
  },
  rulesTotalProfit: {
    color: style.color.lightRed
  },
  rulesItemView: {
    margin: 12 * scale,
    borderBottomWidth: 1 / PixelRatio.get(),
    borderStyle: 'solid',
    borderBottomColor: style.color.gray,
  },
  rulesItem: {
    flexDirection: "row",
    alignItems: 'center',
    // justifyContent: 'center',
    marginBottom: 10 * scale,
  },
  rulesItemText: {
    flex: 1,
    fontSize: 13 * scale
  },
  rulesItemProfit: {
    color: style.color.lightRed,
    textAlign: 'right',
    marginBottom: 14 * scale,
    marginRight: 10 * scale,
    fontSize: 13 * scale
  },
  rulesItemHead: {
    marginBottom: 12 * scale,
    fontSize: 13 * scale
  },
  rulesItemTitleLeft: {
    marginTop: 8 * scale,
    marginBottom: 4 * scale,
    flex: 1,
    fontWeight: 'bold',
    fontSize: 13 * scale
  },
  rulesItemTitleRight: {
    marginTop: 8 * scale,
    marginBottom: 4 * scale,
    flex: 1,
    fontWeight: 'bold',
    fontSize: 13 * scale
  },
  ctInputBox: {
    flexDirection: 'row',
    alignItems: 'center',
    paddingTop: 6 * scale,
    paddingBottom: 6 * scale
  },
  ctInput: {
    fontSize: 13 * scale,
    borderWidth: 1 / PixelRatio.get(),
    borderStyle: 'solid',
    borderColor: style.color.gray,
    height: 24 * scale,
    width: 35 * scale,
    marginRight: 5 * scale,
    paddingVertical: 0,
    textAlign: 'center'
  },
  gangkouSelect: {
    // height: 28 * scale,
    width: 140 * scale,
    flexDirection: 'row',
    alignItems: 'center',
    justifyContent: 'space-between',
    borderWidth: 1 / PixelRatio.get(),
    borderStyle: 'solid',
    borderColor: style.color.gray,
    padding: 6 * scale,
    // paddingRight: 6 * scale,
  },
  ctInputText: {
    fontSize: 13 * scale,
  },
  ctInputTextRed: {
    color: style.color.lightRed
  },
  money: {
    fontWeight: 'bold',
    fontSize: 12 * scale,
    paddingLeft: 5 * scale
  },
  rowbt: {
    flexDirection: 'row',
    alignItems: 'center',
    justifyContent: 'space-between'
  },
  bold: {
    fontSize: 13 * scale,
    fontWeight: 'bold',
    color: '#060606'
  },
  rowItem: { flex: 1 },
  ptop: { paddingTop: 15 * scale, marginBottom: 15 * scale },
  norl: {
    color: '#333',
    fontSize: 13 * scale,
    paddingBottom: 5 * scale
  },
  colorRed: {
    fontSize: 13 * scale,
    color: '#E02020'
  },
  themeColor: {
    color: style.color.themeColor,
    fontSize: 11 * scale
  },
  infoBox: {
    paddingTop: 15 * scale,
    paddingBottom: 10 * scale,
  },
  info: {
    fontSize: 11 * scale,
    paddingBottom: 10 * scale,
    lineHeight: 16 * scale
  },
  bottom: {
    width: '100%',
    flexDirection: 'column',
    alignItems: "center",
    position: 'absolute',
    left: 0,
    bottom: 32 * scale,
  },
  btnBox: {
    width: '100%',
    flexDirection: 'row',
    alignItems: "center",
    justifyContent: 'center',
    marginBottom: 8 * scale
  },
  btnPre: {
    flexDirection: 'row',
    alignItems: 'center',
    justifyContent: 'center',
    marginRight: 12 * scale,
    borderRadius: 6 * scale,
    paddingTop: 10 * scale,
    paddingBottom: 10 * scale,
    paddingLeft: 26 * scale,
    paddingRight: 26 * scale,
    borderColor: style.color.themeColor,
    borderWidth: 1 / PixelRatio.get(),
  },
  btnPreActive: {
    backgroundColor: style.color.themeColor
  },
  btnText: {
    fontSize: 13 * scale,
    fontWeight: 'bold',
    color: style.color.themeColor
  },
  bottomText: {
    fontSize: 11 * scale,
    marginTop: 12 * scale
  },
  fontSize16: {
    fontSize: 16 * scale
  }
})